package leetcode.code0414;

public class Solution2 extends Solution414 {

	long INF = (long) -1e18;

	@Override
	public int thirdMax(int[] nums) {
		// Integer的问题是会有null
		// Integer.MIN_VALUE , 第三大真是Integer.MIN_VALUE的问题
		long a = INF, b = INF, c = INF;
		for (int x : nums) {
			if (x > a) {
				c = b;
				b = a;
				a = x;
			} else if (x < a && x > b) {
				c = b;
				b = x;
			} else if (x < b && x > c) {
				c = x;
			}
		}
		return c != INF ? (int) c : (int) a;
	}

	public static void main(String[] args) {
		Solution2 so = new Solution2();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		so.debug5();
	}

}
